﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Linq.Mapping;
using ECI.Entities;
using ECI.Entities.Builder;
 
namespace ECI.LIP.Entities
{
    ///<summary>
	///[SYS_GENERATE_CONFIG]
	///</summary>
    [Serializable]
	[Table(Name = "SYS_GENERATE_CONFIG")]
    public partial class SysGenerateConfig
	{
		  ///<summary>
          ///[生成单号类型]
          ///</summary>
		  [Column(Storage = "GEN_TYPE")]
	      public string GenType { get { return this._GenType; }  set{ this._GenType=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.GenType); } } 
		  ///<summary>
          ///[生成单号类型名称]
          ///</summary>
		  [Column(Storage = "GEN_TYPE_NAME")]
	      public string GenTypeName { get { return this._GenTypeName; }  set{ this._GenTypeName=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.GenTypeName); } } 
		  ///<summary>
          ///[固定前缀]
          ///</summary>
		  [Column(Storage = "FIXED_PREFIX")]
	      public string FixedPrefix { get { return this._FixedPrefix; }  set{ this._FixedPrefix=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.FixedPrefix); } } 
		  ///<summary>
          ///[生成规则[0-需要,0-不需要](第一位:固定前缀;第二位:业务类型代码;第三位:关区代码;第四位:企业

          ///</summary>
		  [Column(Storage = "GEN_RULE")]
	      public string GenRule { get { return this._GenRule; }  set{ this._GenRule=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.GenRule); } } 
		  ///<summary>
          ///[流水号长度]
          ///</summary>
		  [Column(Storage = "SEQ_LENGTH")]
	      public System.Nullable<double> SeqLength { get { return this._SeqLength; }  set{ this._SeqLength=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.SeqLength); } } 
		  ///<summary>
          ///[备注]
          ///</summary>
		  [Column(Storage = "REMARK")]
	      public string Remark { get { return this._Remark; }  set{ this._Remark=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.Remark); } } 
		  ///<summary>
          ///[扩展字段1]
          ///</summary>
		  [Column(Storage = "EXTEND_FIELD_1")]
	      public string ExtendField1 { get { return this._ExtendField1; }  set{ this._ExtendField1=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.ExtendField1); } } 
		  ///<summary>
          ///[扩展字段2]
          ///</summary>
		  [Column(Storage = "EXTEND_FIELD_2")]
	      public string ExtendField2 { get { return this._ExtendField2; }  set{ this._ExtendField2=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.ExtendField2); } } 
		  ///<summary>
          ///[扩展字段3]
          ///</summary>
		  [Column(Storage = "EXTEND_FIELD_3")]
	      public string ExtendField3 { get { return this._ExtendField3; }  set{ this._ExtendField3=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.ExtendField3); } } 

          ///[扩展字段5]
          ///</summary>
		  [Column(Storage = "EXTEND_FIELD_5")]
	      public System.Nullable<double> ExtendField5 { get { return this._ExtendField5; }  set{ this._ExtendField5=value; if (this.DataModelBegin)AddEnum(SysGenerateConfigEnum.ExtendField5); } } 
		
		/// <summary>
		/// ????????:???????True?,????????,?????????????????????,???????????????????????????????????
		/// </summary>
	    public void StartSetSQLValue()
        {
            this.DataModelBegin = true;
        }

		/// <summary>
		/// ???????
		/// </summary>
        public void EndSetSQLValue()
        {
            this.DataModelBegin = false ;
        }
		
		 private bool DataModelBegin;
		 public List<SysGenerateConfigEnum> ListEnum { get; set; }
		
	     public void AddEnum(SysGenerateConfigEnum item)
         {
            if (ListEnum == null) ListEnum = new List<SysGenerateConfigEnum>();
		    if (!ListEnum.Contains(item))
            {
                ListEnum.Add(item);
            }
          }
		
	 
		
		private  SysGenerateConfigEnum _keyField;
	    public  SysGenerateConfigEnum KeyField { get { return this._keyField;} }

        public void SetKeyField(SysGenerateConfigEnum keyField)
        {
            this.HasSetKeyField = true;
            this._keyField = keyField;
        }
 
        public SysGenerateConfig()
        {
        }

        public SysGenerateConfig(SysGenerateConfigEnum keyField)
        {
            this.HasSetKeyField = true;
            this._keyField = keyField;
        }

        public bool HasSetKeyField { get; set; }
		
		public SysGenerateConfigEnum SortByField { get; set; }
		
		public SortDirection SortDirection { get; set; }
		
		
		public string SQLUpdate
        {
           get{ return new SQLBuilder<SysGenerateConfig, SysGenerateConfigEnum>().Update(this);}
        }

        public string SQLInsert
        {
           get{ return new SQLBuilder<SysGenerateConfig, SysGenerateConfigEnum>().Insert(this);}
        }

        public string SQLDelete
        {
		    get{ return new SQLBuilder<SysGenerateConfig, SysGenerateConfigEnum>().Delete(this);}
        }
		
		public string SQLSelect
        {
            get { return new SQLBuilder<SysGenerateConfig, SysGenerateConfigEnum>().Select(this); }
        }
		
		public void SetAllEnum()
        {
            new SQLBuilder<SysGenerateConfig, SysGenerateConfigEnum>().SetAllEnum(this);
        }

        private DataTable FetchDataTable()
        {
            return FetchDataTable(null);
        }
		
		private DataTable FetchDataTable(object ts)
        {
            return new ECI.Entities.Builder.EntityBuilder<SysGenerateConfig, SysGenerateConfigEnum>().GetDataTable(this,ts);
        }

        /// <summary>
        /// ???????????????????FetchEntity??????
        /// </summary>
	    public bool HasFetchData { get; set; }

        /// <summary>
        /// ??????????????????????FetchEntity??????
        /// </summary>
        public bool NotFetchData{ get { return !HasFetchData; }  }

        /// <summary>
        /// ??????-???????SQL
        /// </summary>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
        public SysGenerateConfig FetchEntity()
        {
           return  FetchEntity("",null);
        }
		
        /// <summary>
        /// ??????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
		public SysGenerateConfig FetchEntity(string sql)
        {
           return  FetchEntity(sql,null);
        }
		
        /// <summary>
        /// ??????-???????SQL
        /// </summary>
        /// <param name="ts">????</param>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
		public SysGenerateConfig FetchEntity(object ts)
        {
           return  FetchEntity("",ts);
        }
		
        /// <summary>
        /// ??????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <param name="ts">????</param>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
		public SysGenerateConfig FetchEntity(string sql,object ts)
        {
            return new ECI.Entities.Builder.EntityBuilder<SysGenerateConfig, SysGenerateConfigEnum>().GetEntity(sql,this,ts);
        }

        /// <summary>
        /// ?????????-???????SQL
        /// </summary>
        /// <returns>??????</returns>
		public List<SysGenerateConfig> FetchEntities()
        {
            return  FetchEntities("",null); 
        }
		
        /// <summary>
        ///  ?????????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <returns>??????</returns>		
	    public List<SysGenerateConfig> FetchEntities(string sql)
        {
            return FetchEntities(sql,null);
        }
		
        /// <summary>
        /// ?????????-???????SQL
        /// </summary>
        /// <param name="ts">????</param>
        /// <returns>??????</returns>
	    public List<SysGenerateConfig> FetchEntities(object ts)
        {
            return FetchEntities("", ts);
        }
		
        /// <summary>
        ///  ?????????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <param name="ts">????</param>
        /// <returns>??????</returns>
	    public List<SysGenerateConfig> FetchEntities(string sql,object ts)
        {
            return new ECI.Entities.Builder.EntityBuilder<SysGenerateConfig, SysGenerateConfigEnum>().GetEntities(sql,this,ts);
        }
		
		/// <summary>
        /// ?????????????
        /// </summary>
        /// <returns>True???? False??????</returns>
		public bool Exists()
        {
            return Exists(null);
        }

        /// <summary>
        ///  ?????????????
        /// </summary>
        /// <param name="ts">????</param>
        /// <returns>True???? False??????</returns>
	    public bool Exists(object ts)
        {
            SysGenerateConfig item = this.FetchEntity(ts);
            return item.HasFetchData;
        }
		
		
		
		
    }
	
	
	public partial class SysGenerateConfig
	{
	      private string _GenType = "";
	      private string _GenTypeName = "";
	      private string _FixedPrefix = "";
	      private string _GenRule = "";
	      private System.Nullable<double> _SeqLength;
	      private string _Remark = "";
	      private string _ExtendField1 = "";
	      private string _ExtendField2 = "";
	      private string _ExtendField3 = "";
	      private System.Nullable<double> _ExtendField5;
    }
 

  public enum  SysGenerateConfigEnum
  {
		  ///<summary>
          ///[生成单号类型]
          ///</summary>
	     GenType ,   
		  ///<summary>
          ///[生成单号类型名称]
          ///</summary>
	     GenTypeName ,   
		  ///<summary>
          ///[固定前缀]
          ///</summary>
	     FixedPrefix ,   
		  ///<summary>
          ///[生成规则[0-需要,0-不需要](第一位:固定前缀;第二位:业务类型代码;第三位:关区代码;第四位:企业

          ///</summary>
	     GenRule ,   
		  ///<summary>
          ///[流水号长度]
          ///</summary>
	     SeqLength ,   
		  ///<summary>
          ///[备注]
          ///</summary>
	     Remark ,   
		  ///<summary>
          ///[扩展字段1]
          ///</summary>
	     ExtendField1 ,   
		  ///<summary>
          ///[扩展字段2]
          ///</summary>
	     ExtendField2 ,   
		  ///<summary>
          ///[扩展字段3]
          ///</summary>
	     ExtendField3 ,   
		  ///<summary>
          ///[扩展字段4]
          ///</summary>
	     ExtendField4 ,   
		  ///<summary>
          ///[扩展字段5]
          ///</summary>
	     ExtendField5    
   }
}
